<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
</head>
<body id="body">

<div>
        <h1 id="heading">Steps</h1>

        <main id="main" tabindex=0>
         test
                <div class="step-one" aria-hidden="true"><span>Step 1: Do something</span></div>
                <div class="step-two" aria-hidden="true"><span>Step 2: Do another thing</span></div>
                <div class="step-three" aria-hidden="true"><span>Step 3: Do one last thing</span></div>
        </main>

</div>


<p id="description"></p>
<div id="console"></div>

<script>

function axElementById(id) {
    return accessibilityController.accessibleElementById(id);
}

test((t) => {
    var main = axElementById("main");
    assert_equals(main.childrenCount, 4);
    assert_false(main.childAtIndex(0).isIgnored);
    assert_true(main.childAtIndex(1).isIgnored);
    assert_true(main.childAtIndex(2).isIgnored);
    assert_true(main.childAtIndex(3).isIgnored);

    var group = document.getElementsByTagName('main')[0];
    var items = group.getElementsByTagName('div');
    items[0].removeAttribute('aria-hidden');

    assert_equals(main.childrenCount, 4,
                  "After removing aria-hidden, the count should still be 4.");
    assert_false(main.childAtIndex(0).isIgnored);
    assert_false(main.childAtIndex(1).isIgnored);
    assert_true(main.childAtIndex(2).isIgnored);
    assert_true(main.childAtIndex(3).isIgnored);

    // And most importantly...
    assert_equals(main.childAtIndex(1).childrenCount, 1,
                      "The DIV that was made non-hidden should have one child now.");
}, "This tests that if aria-hidden changes on an element, all it's existing children will update their children caches");

</script>

</body>
</html>
